package com.usian.mapper;

import com.usian.pojo.Ygong;
import com.usian.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface EtcMapper {

    @Select("select * from ygong y, bum b where y.bum=b.id and name like '%${name}%'")
    public List<Ygong> findAll(Ygong etc);

    @Select("select * from ygong where id = #{id}")
    public Ygong findById(@Param("id") Integer id);

    @Insert("INSERT INTO `p10`.`ygong`(`id`, `name`, `sex`, `sr`, `rzsj`, `xueli`, `zhiwu`, `zhuzhi`, `dianhua`, `lxr`, `bum`) VALUES (NULL, #{name}, #{sex}, #{sr}, #{rzsj}, #{xueli}, #{zhiwu}, #{zhuzhi}, #{dianhua}, #{lxr}, #{bum})")
    public void insertEtc(Ygong etc);

    @Delete("delete from ygong where id = #{id}")
    public void deleteById(@Param("id") Integer id);

    @Update("update ygong SET `name` = #{name}, `sex` = #{sex}, `sr` = #{sr}, `rzsj` = #{rzsj}, `xueli` = #{xueli}, `zhiwu` = #{zhiwu}, `zhuzhi` = #{zhuzhi},`dianhua` = #{dianhua}, `lxr` = #{lxr}, `bum` = #{bum} WHERE `id` = #{id}")
    public void update(Ygong etc);
    //UPDATE `p10`.`ygong` SET `name` = '#{name}', `sex` = #{sex}, `sr` = #{sr}, `rzsj` = #{rzsj}, `xueli` = #{xueli}, `zhiwu` = #{zhiwu}, `zhuzhi` = #{zhuzhi},`dianhua` = #{dianhua}, `lxr` = #{lxr}, `bum` = #{bum} WHERE `id` IS #{id};

    @Insert("INSERT INTO `p10`.`user`(`id`, `name`, `password`, `czsj`, `jsid`) VALUES (null, #{name}, #{password}, #{czsj}, #{jsid})")
    void adduser(User user);

    @Select("select * from user where name=#{name} and password=#{password}")
    User denglu(User user);
}
